package gjtx4;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

public class MapUse1 {
    public static void main(String[] args) {
        Map<String, String> m = new HashMap<>();
        m.put("狗", "dog");
        m.put("猪", "pig");
        m.put("猫", "cat");
        m.put("牛", "cow");
        m.put("羊", "sheep");
        m.put("鸡", "chicken");
        m.put("老虎", "tiger");
        m.put(null, "horse");
        m.put("狮子", "lion");
        m.put("猎豹", "cheetah");
        m.put("炸弹", "马");
        System.out.println(m);
        System.out.println(">>>>>>>>>>>>>>");
        Iterator ie=m.keySet().iterator();
        System.out.println(ie.next());
        System.out.println(">>>>>>>>>>>>>>>");
        Scanner in = new Scanner(System.in);
        System.out.println("请输入中文");
        String str = in.next();
        if (!m.containsKey(str)) {
            System.out.println("不存在!");
        } else {
            Iterator<String> ir = m.keySet().iterator();
            while (ir.hasNext()) {
                String k = ir.next();
                String v = m.get(k);
                if (str.equals(k)) {
                    System.out.println(v);
                }
            }
        }
        System.out.println("请输入英文！");
        String str1=in.next();
        if (!m.containsValue(str1)) {
            System.out.println("不存在!");
        } else {
            Iterator<String> ir = m.keySet().iterator();
            while (ir.hasNext()) {
                String k = ir.next();
                String v = m.get(k);
                if (str1.equals(v)) {
                    System.out.println(k);
                }
            }
        }
    }
}